package com.wude.guild.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wude.bean.AppInfo;
import com.wude.guild.fragment.MyCollectionFragment;
import com.wude.guild.holder.MyshouHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * 我的收藏Adapter
 * Created by Administrator on 2017/3/20.
 */

public class MyCollectionListAdapter extends BaseAdapter {

    private final Activity con;
    public List<AppInfo> list = new ArrayList<AppInfo>();
    private MyCollectionFragment fragment;

    public MyCollectionListAdapter(Activity activity, MyCollectionFragment fragment) {
        this.con = activity;
        this.fragment = fragment;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyshouHolder holder = null;

        if (convertView == null) {
            holder = new MyshouHolder(fragment);
        } else {
            holder = (MyshouHolder) convertView.getTag();
        }
        AppInfo appInfo = list.get(position);
        holder.setData(appInfo, position, con);
        return holder.getContentView();
    }


    public void setList(List<AppInfo> b) {
        this.list = b;
        notifyDataSetChanged();
    }

    public List<AppInfo> getList() {
        return list;
    }
}
